//package com.heima.Interceptor;
//
//import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
//import com.heima.utils.JwtUtils;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//@Component
//public class UserInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        //1、获取请求头令牌
//        String token = request.getHeader("token");
//
//        //2、令牌校验(令牌为空，或者令牌解析不通过，都要拦截)
//        if(ObjectUtils.isEmpty(token) || JwtUtils.parseJWT(token)==null){
//            response.setStatus(401);
//            return false;
//        }
//
//        //3、校验通过，放行请求
//        return true;
//    }}